package com.sinosoft.comm.condition;

import com.sinosoft.comm.enums.DelFlagEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.List;

/**
 * eq_bean等于
 * lk_
 * llk_
 * rlk_
 * <p>
 * gt_ 大于
 * lt_ 小于
 * ge_ 大于等于
 * le_小于等于
 * in_
 * null_ 是否为空
 */
@Data
@ApiModel(description = "条件")
public abstract class BaseCondition {

    @ApiModelProperty(value = "页码", position = 1,example = "1")
    private Integer page = 1;
    @ApiModelProperty(value = "页长", position = 2,example = "10")
    private Integer rows = 10;
    @ApiModelProperty(value = "当前页码", position = 3,example = "1")
    private Integer currentPage;


    /**
     * @Fields defaultName : TODO(默认的filter 名称)
     */
    @ApiModelProperty(hidden = true)
    public String defaultName = "filter";

    /**
     * @Fields defaultFormId : TODO(默认的listForm ID)
     */
    @ApiModelProperty(hidden = true)
    public String defaultFormId = "listForm";
    @ApiModelProperty(value = "有效字段", position = 4,example = "1")
    public Integer eq_delFlag = DelFlagEnum.YES.getDelFlag();
    @ApiModelProperty(value = "多个 ID", position = 4)
    public List<String> in_id;
    @ApiModelProperty(value = "排序sql", position = 4,example = " id desc ")
    public String orderbyField = " id desc ";
    @ApiModelProperty(hidden = true)
    public String key;
    @ApiModelProperty(hidden = true)
    public Integer pageStrType = 0;


    public Integer getPageStrType() {
        return pageStrType;
    }

    public void setPageStrType(Integer pageStrType) {
        this.pageStrType = pageStrType;
    }

    public Integer getPage() {
        return page;
    }

    public void setPage(Integer page) {
        this.page = page;
    }

    public Integer getRows() {
        return rows;
    }

    public void setRows(Integer rows) {
        this.rows = rows;
    }

    public String getDefaultName() {
        return defaultName;
    }

    public void setDefaultName(String defaultName) {
        this.defaultName = defaultName;
    }

    public String getDefaultFormId() {
        return defaultFormId;
    }

    public void setDefaultFormId(String defaultFormId) {
        this.defaultFormId = defaultFormId;
    }

    public Integer getEq_delFlag() {
        return eq_delFlag;
    }

    public void setEq_delFlag(Integer eq_delFlag) {
        this.eq_delFlag = eq_delFlag;
    }

    public List<String> getIn_id() {
        return in_id;
    }

    public void setIn_id(List<String> in_id) {
        this.in_id = in_id;
    }

    public String getOrderbyField() {
        return orderbyField;
    }

    public void setOrderbyField(String orderbyField) {
        this.orderbyField = orderbyField;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }


    public void setCurrentPage(Integer currentPage) {
        if (currentPage == null) {
            currentPage = 1;
        }
        if (currentPage == 0) {
            currentPage = 1;
        }
        this.currentPage = this.rows.intValue() * (currentPage == 0 ? 1 : currentPage - 1);
    }

    public Integer getCurrentPage() {
        return currentPage;
    }

}
